package likong.bibliothek.pages.status;

import likong.bibliothek.obj.BuchStatus;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.hibernate.Session;

import db.HibernateHelper;

public class StatusNeu extends StatusAbstract{
	public StatusNeu(){
		BuchStatus status = new BuchStatus();
		final CompoundPropertyModel<BuchStatus> model = new CompoundPropertyModel<BuchStatus>(status);
		
		// Panel einfügen
		add(new StatusFormPanel("neuerStatusFormular", model, "Spender einfügen") {
			private static final long serialVersionUID = 1L;

			@Override
			protected void onSubmitModelHandle(IModel<BuchStatus> model) {
				Session session = HibernateHelper.getSessionFactory().getCurrentSession();
				session.beginTransaction();
				session.save(model.getObject());
				session.getTransaction().commit();
//				session.close();
				this.setResponsePage(StatusWeb.class);
			}
		});
	}

}
